<template>
    <div class="header-container">
        <div class="l-content">
            <el-button style="margin-right: 20px;" @click="handleMenu" icon="el-icon-menu" size="mini"></el-button>
            <!-- <span class="text">首页</span> -->
            <!-- 面包屑 -->
            <el-breadcrumb separator="/">
                <el-breadcrumb-item v-for="item in tags" :key="item.path" :to="{ path: item.path }">
                    {{ item.label }}</el-breadcrumb-item>
                <!-- <el-breadcrumb-item><a href="/">活动管理</a></el-breadcrumb-item>
                <el-breadcrumb-item>活动列表</el-breadcrumb-item>
                <el-breadcrumb-item>活动详情</el-breadcrumb-item> -->
            </el-breadcrumb>
        </div>
        <div class="r-content">
            <el-dropdown @command="handeClick">
                <span class="el-dropdown-link">
                    <img class="user" src="../assets/images/user.png" alt="">
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>个人中心</el-dropdown-item>
                    <el-dropdown-item command="cancel"> 退出</el-dropdown-item>
                  
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
    
</template>
<script>
    import { mapState } from 'vuex';
    import Cookie from 'js-cookie';

    export default {
        data() {
            return {}
        },
        methods: {
            handleMenu(){
                // 获取 store 中的数据
                this.$store.commit('collapseMenu')
            },
            handeClick(command){
                if(command === 'cancel'){
                    Cookie.remove('token')
                    // 清除 cookie 中的menu
                    Cookie.remove('menu')
                    this.$router.push('/login')
                }
            }
        },
        computed: {
            ...mapState({
                tags: state => state.tab.tabsList
            })
        },
        mounted(){

            console.log(this.tags, "tags-header")
        }
    }
</script>
<style lang="less" scoped>
.header-container {
    background: #333;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    .text {
        color: #fff;
        font-size: 14px;
        margin-left: 10px;
    }
    .r-content {
        .user {
            width: 40px;
            height: 40px;
            border-radius: 50%;
        }
    }
    .l-content {
        display: flex;
        align-items: center;
        /deep/.el-breadcrumb__item {  // 样式穿刺
            .el-breadcrumb__inner {
                font-weight: normal;
                &.is-link {  // & 并且
                    color: #666;
                }
            }
            &:last-child {
                .el-breadcrumb__inner {
                    color: #fff;
                }
            }
        }
    }
}
</style>